﻿<%@ Page Title="Консолидированный счет" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ConsolidatedAccount.aspx.cs" Inherits="Otgruzka.WebForms.ConsolidatedAccount" %>
<%@ Register Src="~/Controls/jQuery/JQueryDatepicker.ascx" TagPrefix="custom" TagName="Datepicker" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <table id="ConsolidatedAccountInfo" width="100%">
        <tr>
            <td style="width: 80%;">
                <div>
                    <asp:UpdatePanel ID="ConsolidatedAccountUpdatePanel" runat="server">
                    <ContentTemplate>

                 <h1><%=TitleMessage %></h1>
                <h3><%=StatusName%></h3>

                <div class='<%= (ErrorMessage.Text.Length==0) ? "hidden" : "showen" %>'>
                    <div id="error_string" class="cError"><asp:Label ID="ErrorMessage" runat="server" /></div>
                </div>

                <div id="filters">
                    <table border="0" width="50%" cellpadding="4">
                        <tr>
                            <td style="white-space:nowrap;">
                                Юридическое лицо:
                            </td>
                            <td width="100%">
                                <asp:DropDownList ID="ddlJuridicalPersons" DataTextField="Name" DataValueField="JuridicalPersonId" runat="server" Width="67%" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">Период</td>
                        </tr>
                        <tr>
                            <td style="white-space:nowrap;">
                                Дата начала:
                            </td>
                            <td width="100%">
                                <custom:Datepicker runat="server" ID="dpDateBegin" />
                            </td>
                        </tr>
                        <tr>
                            <td style="white-space:nowrap;">
                                Дата окончания:
                            </td>
                            <td width="100%">
                                <custom:Datepicker runat="server" ID="dpDateEnd" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:Button runat="server" id="btnCreateConsolidatedAccount" Text="Сформировать" OnClick="btnCreateConsolidatedAccount_Click" />&nbsp;
                                <asp:Button runat="server" id="btnNewConsolidatedAccount" Text="Новый" OnClick="btnNewConsolidatedAccount_Click" />
                            </td>
                        </tr>
                    </table>
                </div>


                       <div id="UpdatePanelContent">
                            <div id="ProductsGridView">
                                <asp:GridView ID="Products" Runat="server" 
                                        AutoGenerateColumns="False" 
                                        CellPadding="5" 
                                        ShowEmptyHeader="True" 
                                        ShowFooter="true" 
                                        GridLines="Vertical"
                                        AllowSorting="true" OnSorting="ProductsGridView_Sorting"
                                        OnRowCreated="Products_RowCreated"
                                        OnRowDataBound="Products_RowDataBound">
                                    <EmptyDataTemplate>Нет товаров</EmptyDataTemplate>
                                    <Columns>
                                        <asp:TemplateField HeaderText="№" HeaderStyle-Font-Size="8pt" HeaderStyle-Wrap="false">
                                            <ItemTemplate>
                                                <asp:Label ID="RowId" Text='<%# Eval("RowId")%>' runat="server" />
                                            </ItemTemplate>
                                            <FooterTemplate>ИТОГО:</FooterTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="ID товара" ItemStyle-HorizontalAlign="Center" SortExpression="ProductId" HeaderStyle-Font-Size="8pt" HeaderStyle-Wrap="false">
                                            <ItemTemplate>
                                                <asp:Label ID="ProductId" Text='<%# Eval("ProductId")%>' runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Наименование" HeaderStyle-Width="70%" SortExpression="ProductName" HeaderStyle-Font-Size="8pt" HeaderStyle-Wrap="false">
                                            <ItemTemplate>
                                                <asp:Label ID="ProductName" Text='<%# Eval("ProductName")%>' runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Цена (с НДС)" ItemStyle-HorizontalAlign="Right" SortExpression="Price" HeaderStyle-Font-Size="8pt" HeaderStyle-Wrap="false">
                                            <ItemTemplate>
                                                <asp:Label ID="Price" Text='<%# string.Format("{0:C2}", Eval("Price"))%>' runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Кол-во" ItemStyle-HorizontalAlign="Right" SortExpression="Count" HeaderStyle-Font-Size="8pt" HeaderStyle-Wrap="false">
                                            <ItemTemplate>
                                                <asp:Label ID="Quantity" Text='<%# Eval("Count")%>' runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Сумма (с НДС)" ItemStyle-HorizontalAlign="Right" SortExpression="Summa" HeaderStyle-Font-Size="8pt" HeaderStyle-Wrap="false">
                                            <ItemTemplate>
                                                <asp:Label ID="Summa" Text='<%# string.Format("{0:C2}", Eval("Summa"))%>' runat="server" />
                                            </ItemTemplate>
                                            <FooterStyle HorizontalAlign="Right" />
                                            <FooterTemplate><asp:label id="ItogoTotalLabel" runat="server"/></FooterTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <SelectedRowStyle BackColor="#6b8cbe" ForeColor="DarkBlue" Font-Bold="true"/> 
                                    <RowStyle BackColor="White" />
                                    <AlternatingRowStyle BackColor="#DdDdDd" />
                                </asp:GridView>
                            </div>
            
                            <br /><br /><br />
                            <div style="clear:both;"></div>
                            <p>
                                <asp:Button runat="server" Text="Сохранить" ID="btnSaveConsolidatedAccount" OnClick="btnSaveConsolidatedAccount_Click" />
                                <asp:Button runat="server" Text="Исполнить" ID="btnExecConsolidatedAccount" OnClick="btnExecConsolidatedAccount_Click" />
                                <script>
                                    function openprintwin() { 
//                                        var caid = <%= Request.QueryString["caid"] %>;
//                                        window.open('/WebForms/ConsolidatedAccountPrint.aspx?caid='+caid,'print');
                                        window.open('<%=string.Format("{0}?caid={1}", ResolveUrl("~/WebForms/ConsolidatedAccountPrint.aspx"), Request.QueryString["caid"]) %>','print');
                                    }
                                </script>
                                <asp:Button runat="server" Text="Распечатать" ID="btnPrintConsolidatedAccount" OnClientClick="javascript: openprintwin(); return false;" />
                            </p>
                        </div>
                    </ContentTemplate>
                    </asp:UpdatePanel>
                    <asp:UpdateProgress ID="progressBar" runat="server" AssociatedUpdatePanelID="ConsolidatedAccountUpdatePanel">
                        <ProgressTemplate>
                            <div id="closebg">
                                <div id="centered">
                                    <asp:Image ID="ProgressImage" runat="server" ImageUrl="~/Images/ajax-loader.gif" style="vertical-align:middle; text-align:center;" AlternateText="Проверяются введенные данные" />
                                </div>
                            </div>
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                </div>
                
                <p>
                <%--<div style="float:right;">--%>
                    <asp:Button runat="server" id="btnOtgruzkaExcel" Text="Excel - Отгрузка" OnClick="btnOtgruzkaExcel_Click" />
                    <asp:Button runat="server" id="btnInvoiceExcel" Text="Excel - Накладная" OnClick="btnInvoiceExcel_Click" />
                <%--</div>--%>
                </p>

            </td>
            <td style="width: 20%;">
                <asp:Repeater ID="PromptMessagesRepeater" runat="server" Visible="false">
                    <ItemTemplate>
                        <div class="helpdiv" style="margin: 2px;">
                            <asp:Label ID="id" runat="server">
                            <%# Container.DataItem %>
                            </asp:Label>
                        </div>
                    </ItemTemplate>
                </asp:Repeater>
           </td>
        </tr>
    </table>
    
</asp:Content>
